/**
 * @param {number[][]} matrix
 * @return {void} Do not return anything, modify matrix in-place instead.
 */
var setZeroes = function(matrix) {
    var x = new Set();
    var y = new Set();
    for (var i = 0; i < matrix.length; i++) {
        for ( var j = 0;j < matrix[i].length; j++) {
            if( matrix[i][j] == 0 ) {
                x.add(i);
                y.add(j);
            }
        }
    }
    x.forEach(function (item) {
       for (var i = 0; i < matrix[0].length; i++) {
           if (matrix[item][i] != 0) {
                matrix[item][i] = 0
           }
       }
    })
    y.forEach(function (item) {
        for (var i = 0; i < matrix.length; i++) {
            if (matrix[i][item] != 0) {
                matrix[i][item] = 0
            }
        }
    })
    return matrix
};

console.log(setZeroes([
    [0,1,2,0],
    [3,4,5,2],
    [1,3,1,5]
]))